<?php
class Poll extends PollsAppModel {

	var $name = 'Poll';
	var $validate = array(
		'title' => array('notempty'),
		'activo' => array('numeric'),
		'home' => array('numeric')
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $hasMany = array(
		'PollOption' => array(
			'className' => 'PollOption',
			'foreignKey' => 'poll_id',
			'dependent' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);
	
	function votar($option_id = null){
		if (!$option_id){
			return false;
		}
		$this->query('UPDATE poll_options SET votos = votos + 1 WHERE id = '.$option_id.';');
	}

}
?>